﻿using System;
using System.Collections.Generic;
using System.Reflection;
#if USE_UNI_LUA
using LuaAPI = UniLua.Lua;
using RealStatePtr = UniLua.ILuaState;
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
#else
using LuaAPI = XLua.LuaDLL.Lua;
using RealStatePtr = System.IntPtr;
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
#endif

namespace XLua.CSObjectWrap
{
    public class XLua_Gen_Initer_Register__
    {
        static void wrapInit0(LuaEnv luaenv, ObjectTranslator translator)
        {
            translator.DelayWrapLoader(typeof(object), SystemObjectWrap.__Register);

            translator.DelayWrapLoader(
                typeof(UnityEngine.Object),
                UnityEngineObjectWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Vector2),
                UnityEngineVector2Wrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Vector3),
                UnityEngineVector3Wrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Vector4),
                UnityEngineVector4Wrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Quaternion),
                UnityEngineQuaternionWrap.__Register
            );

            translator.DelayWrapLoader(typeof(UnityEngine.Color), UnityEngineColorWrap.__Register);

            translator.DelayWrapLoader(typeof(UnityEngine.Ray), UnityEngineRayWrap.__Register);

            translator.DelayWrapLoader(
                typeof(UnityEngine.Bounds),
                UnityEngineBoundsWrap.__Register
            );

            translator.DelayWrapLoader(typeof(UnityEngine.Ray2D), UnityEngineRay2DWrap.__Register);

            translator.DelayWrapLoader(typeof(UnityEngine.Time), UnityEngineTimeWrap.__Register);

            translator.DelayWrapLoader(
                typeof(UnityEngine.GameObject),
                UnityEngineGameObjectWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Component),
                UnityEngineComponentWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Behaviour),
                UnityEngineBehaviourWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Transform),
                UnityEngineTransformWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Resources),
                UnityEngineResourcesWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.TextAsset),
                UnityEngineTextAssetWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Keyframe),
                UnityEngineKeyframeWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.AnimationCurve),
                UnityEngineAnimationCurveWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.AnimationClip),
                UnityEngineAnimationClipWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.MonoBehaviour),
                UnityEngineMonoBehaviourWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.ParticleSystem),
                UnityEngineParticleSystemWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.SkinnedMeshRenderer),
                UnityEngineSkinnedMeshRendererWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(UnityEngine.Renderer),
                UnityEngineRendererWrap.__Register
            );

            translator.DelayWrapLoader(typeof(UnityEngine.Light), UnityEngineLightWrap.__Register);

            translator.DelayWrapLoader(typeof(UnityEngine.Mathf), UnityEngineMathfWrap.__Register);

            translator.DelayWrapLoader(
                typeof(System.Collections.Generic.List<int>),
                SystemCollectionsGenericList_1_SystemInt32_Wrap.__Register
            );

            translator.DelayWrapLoader(typeof(UnityEngine.Debug), UnityEngineDebugWrap.__Register);

            translator.DelayWrapLoader(
                typeof(Tutorial.BaseClass),
                TutorialBaseClassWrap.__Register
            );

            translator.DelayWrapLoader(typeof(Tutorial.TestEnum), TutorialTestEnumWrap.__Register);

            translator.DelayWrapLoader(
                typeof(Tutorial.DerivedClass),
                TutorialDerivedClassWrap.__Register
            );

            translator.DelayWrapLoader(typeof(Tutorial.ICalc), TutorialICalcWrap.__Register);

            translator.DelayWrapLoader(
                typeof(Tutorial.DerivedClassExtensions),
                TutorialDerivedClassExtensionsWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(XLuaTest.LuaBehaviour),
                XLuaTestLuaBehaviourWrap.__Register
            );

            translator.DelayWrapLoader(typeof(XLuaTest.Pedding), XLuaTestPeddingWrap.__Register);

            translator.DelayWrapLoader(typeof(XLuaTest.MyStruct), XLuaTestMyStructWrap.__Register);

            translator.DelayWrapLoader(typeof(XLuaTest.MyEnum), XLuaTestMyEnumWrap.__Register);

            translator.DelayWrapLoader(typeof(XLuaTest.NoGc), XLuaTestNoGcWrap.__Register);

            translator.DelayWrapLoader(
                typeof(UnityEngine.WaitForSeconds),
                UnityEngineWaitForSecondsWrap.__Register
            );

            translator.DelayWrapLoader(typeof(XLuaTest.BaseTest), XLuaTestBaseTestWrap.__Register);

            translator.DelayWrapLoader(
                typeof(XLuaTest.Foo1Parent),
                XLuaTestFoo1ParentWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(XLuaTest.Foo2Parent),
                XLuaTestFoo2ParentWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(XLuaTest.Foo1Child),
                XLuaTestFoo1ChildWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(XLuaTest.Foo2Child),
                XLuaTestFoo2ChildWrap.__Register
            );

            translator.DelayWrapLoader(typeof(XLuaTest.Foo), XLuaTestFooWrap.__Register);

            translator.DelayWrapLoader(
                typeof(XLuaTest.FooExtension),
                XLuaTestFooExtensionWrap.__Register
            );

            translator.DelayWrapLoader(
                typeof(Tutorial.DerivedClass.TestEnumInner),
                TutorialDerivedClassTestEnumInnerWrap.__Register
            );
        }

        static void Init(LuaEnv luaenv, ObjectTranslator translator)
        {
            wrapInit0(luaenv, translator);

            translator.AddInterfaceBridgeCreator(
                typeof(System.Collections.IEnumerator),
                SystemCollectionsIEnumeratorBridge.__Create
            );

            translator.AddInterfaceBridgeCreator(
                typeof(XLuaTest.IExchanger),
                XLuaTestIExchangerBridge.__Create
            );

            translator.AddInterfaceBridgeCreator(
                typeof(Tutorial.CSCallLua.ItfD),
                TutorialCSCallLuaItfDBridge.__Create
            );

            translator.AddInterfaceBridgeCreator(
                typeof(XLuaTest.InvokeLua.ICalc),
                XLuaTestInvokeLuaICalcBridge.__Create
            );
        }

        static XLua_Gen_Initer_Register__()
        {
            XLua.LuaEnv.AddIniter(Init);
        }
    }
}

namespace XLua
{
    public partial class ObjectTranslator
    {
        static XLua.CSObjectWrap.XLua_Gen_Initer_Register__ s_gen_reg_dumb_obj =
            new XLua.CSObjectWrap.XLua_Gen_Initer_Register__();
        static XLua.CSObjectWrap.XLua_Gen_Initer_Register__ gen_reg_dumb_obj
        {
            get { return s_gen_reg_dumb_obj; }
        }
    }

    internal partial class InternalGlobals
    {
        static InternalGlobals()
        {
            extensionMethodMap = new Dictionary<Type, IEnumerable<MethodInfo>>() { };

            genTryArrayGetPtr = StaticLuaCallbacks.__tryArrayGet;
            genTryArraySetPtr = StaticLuaCallbacks.__tryArraySet;
        }
    }
}
